import request from "@/utils/request";
import {SysFileQuery,SysFileForm} from "./model";
import axios from "axios";

class SysFileAPI {

    static query(queryParams?: SysFileQuery) {
        return request<any, ApiResult>({
            url: "/api/sysFile/query",
            method: "post",
            data: queryParams,
        });
    }

    static add(data: SysFileForm) {
        return request({
            url: "/api/sysFile/add",
            method: "post",
            data: data,
        });
    }

    static edit(data: SysFileForm) {
        return request({
            url: "/api/sysFile/edit",
            method: "post",
            data: data,
        });
    }

    static delete(ids: string) {
        return request({
            url: "/api/sysFile/delete",
            method: "post",
            data: {ids: ids},
        });
    }

    static service(service: string, data: any = {}, config: any = {}) {
        let headers = {
            'Content-Type': 'application/x-www-form-urlencoded'
        }
        return request({
            url: "/api/sysFile/" + service,
            method: "post",
            data: data,
            headers: Object.assign(headers, config)
        });
    }

    static download(service: string, data: any = {}, responseType: axios.ResponseType = 'blob') {
        return request({
            url: "/api/sysFile/"+service,
            method: "get",
            params: data,
            responseType: responseType
        });
    }
}

export default SysFileAPI;
